/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package presentacion;

import entities.Categoria;
import entities.Estadio;
import entities.Fase;
import entities.Partido;
import entities.Precio;
import entities.Silla;
import entities.Sillaxpartido;
import java.awt.Label;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.swing.AbstractButton;
import javax.swing.ButtonGroup;
import javax.swing.ButtonModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JCheckBox;
import javax.swing.JOptionPane;
import javax.swing.JRadioButton;
import javax.swing.JTable;
import javax.swing.UIDefaults;
import javax.swing.UIManager;
import javax.swing.event.TableModelEvent;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;
import logicanegocio.FaseJpaController;

/**
 *
 * @author Alejandro
 */
public class Mundial_GUI extends javax.swing.JFrame {

    private static final EntityManagerFactory emf = Persistence.createEntityManagerFactory("Sistema_Informacion_Mundial_2014PU");
    private Sistema_Mundial sistema = new Sistema_Mundial();
    private Partido partidoSeleccionadoVenta;

    /**
     * Creates new form Prueba_Mundial_GUI
     */
    public Mundial_GUI() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jFrameVentaBoleteria = new javax.swing.JFrame();
        jButtonRegresarVentasBol1 = new javax.swing.JButton();
        label1 = new java.awt.Label();
        label2 = new java.awt.Label();
        label3 = new java.awt.Label();
        labelFechaActual = new java.awt.Label();
        labelHoraActual = new java.awt.Label();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTableCalendarioPartidos = new javax.swing.JTable()
        {
            public void tableChanged(TableModelEvent e) {
                super.tableChanged(e);
                repaint();
            }
        };
        jButtonSolicitarEntradas = new javax.swing.JButton();
        jComboBoxFases = new javax.swing.JComboBox();
        jButtonCargarFase = new javax.swing.JButton();
        butGruopPartidosVentaBol = new javax.swing.ButtonGroup();
        jFrameEntradasPorCategoria = new javax.swing.JFrame();
        label4 = new java.awt.Label();
        label5 = new java.awt.Label();
        labelNomEstadio = new java.awt.Label();
        label6 = new java.awt.Label();
        labelNumPartido = new java.awt.Label();
        label7 = new java.awt.Label();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTableCategoriaVentaBol = new javax.swing.JTable()
        {
            public void tableChanged(TableModelEvent e) {
                super.tableChanged(e);
                repaint();
            }
        }
        ;
        jButtonRegresarCategoria = new javax.swing.JButton();
        jButtonSolicitarEntradasCate = new javax.swing.JButton();
        jFrameSeleccionSillas = new javax.swing.JFrame();
        labelFrameSillas1 = new java.awt.Label();
        labelFrameSillas2 = new java.awt.Label();
        labelFrameSillasEstadio = new java.awt.Label();
        labelFrameSillas3 = new java.awt.Label();
        labelFrameSillasIdPartido = new java.awt.Label();
        labelFrameSillas4 = new java.awt.Label();
        labelFrameSillasNumCat = new java.awt.Label();
        labelFrameSillas5 = new java.awt.Label();
        labelFrameSillasNumDis = new java.awt.Label();
        jButtonFrameSillasRegresar = new javax.swing.JButton();
        jButtonFrameSillasComprar = new javax.swing.JButton();
        jScrollPane3 = new javax.swing.JScrollPane();
        jTableSillasDisponibles = new javax.swing.JTable();
        jButtonVentaBoleteria = new javax.swing.JButton();

        jFrameVentaBoleteria.setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        jFrameVentaBoleteria.setTitle("Venta de boleteria");
        jFrameVentaBoleteria.setBounds(new java.awt.Rectangle(100, 50, 700, 360));
        jFrameVentaBoleteria.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));

        jButtonRegresarVentasBol1.setText("Regresar");
        jButtonRegresarVentasBol1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButtonRegresarVentasBol1MouseClicked(evt);
            }
        });
        jButtonRegresarVentasBol1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonRegresarVentasBol1ActionPerformed(evt);
            }
        });

        label1.setText("Disponibilidad de entradas por partido.  Fase de eliminatoria ");

        label2.setText("Fecha Actual");

        label3.setText("Hora Actual");

        labelFechaActual.setText("label4");

        labelHoraActual.setText("label4");

        jTableCalendarioPartidos.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jTableCalendarioPartidos.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTableCalendarioPartidosMouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(jTableCalendarioPartidos);

        jButtonSolicitarEntradas.setText("Solicitar Entradas");
        jButtonSolicitarEntradas.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButtonSolicitarEntradasMouseClicked(evt);
            }
        });
        jButtonSolicitarEntradas.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonSolicitarEntradasActionPerformed(evt);
            }
        });

        jComboBoxFases.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        jButtonCargarFase.setText("Cargar fase");
        jButtonCargarFase.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButtonCargarFaseMouseClicked(evt);
            }
        });
        jButtonCargarFase.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonCargarFaseActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jFrameVentaBoleteriaLayout = new javax.swing.GroupLayout(jFrameVentaBoleteria.getContentPane());
        jFrameVentaBoleteria.getContentPane().setLayout(jFrameVentaBoleteriaLayout);
        jFrameVentaBoleteriaLayout.setHorizontalGroup(
            jFrameVentaBoleteriaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jFrameVentaBoleteriaLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jFrameVentaBoleteriaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(label1, javax.swing.GroupLayout.PREFERRED_SIZE, 414, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jFrameVentaBoleteriaLayout.createSequentialGroup()
                        .addComponent(jButtonRegresarVentasBol1)
                        .addGap(128, 128, 128)
                        .addComponent(jButtonSolicitarEntradas, javax.swing.GroupLayout.PREFERRED_SIZE, 175, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jFrameVentaBoleteriaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jFrameVentaBoleteriaLayout.createSequentialGroup()
                            .addGroup(jFrameVentaBoleteriaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addComponent(label2, javax.swing.GroupLayout.DEFAULT_SIZE, 87, Short.MAX_VALUE)
                                .addComponent(label3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(jFrameVentaBoleteriaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addComponent(labelFechaActual, javax.swing.GroupLayout.DEFAULT_SIZE, 70, Short.MAX_VALUE)
                                .addComponent(labelHoraActual, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addGroup(jFrameVentaBoleteriaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addComponent(jButtonCargarFase, javax.swing.GroupLayout.DEFAULT_SIZE, 116, Short.MAX_VALUE)
                                .addComponent(jComboBoxFases, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 660, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(101, Short.MAX_VALUE))
        );
        jFrameVentaBoleteriaLayout.setVerticalGroup(
            jFrameVentaBoleteriaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jFrameVentaBoleteriaLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(label1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jFrameVentaBoleteriaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(label2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(labelFechaActual, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jComboBoxFases, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jFrameVentaBoleteriaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jFrameVentaBoleteriaLayout.createSequentialGroup()
                        .addGroup(jFrameVentaBoleteriaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(label3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(labelHoraActual, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 169, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jFrameVentaBoleteriaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jButtonRegresarVentasBol1)
                            .addComponent(jButtonSolicitarEntradas)))
                    .addComponent(jButtonCargarFase))
                .addContainerGap(87, Short.MAX_VALUE))
        );

        label1.getAccessibleContext().setAccessibleDescription("");

        jFrameEntradasPorCategoria.setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        jFrameEntradasPorCategoria.setTitle("Venta de boleteria");
        jFrameEntradasPorCategoria.setBounds(new java.awt.Rectangle(100, 50, 450, 315));

        label4.setText("Disponibilidad de entradas por categoria");

        label5.setText("Estadio");

        labelNomEstadio.setText("label6");

        label6.setText("Partido");

        labelNumPartido.setText("label7");

        label7.setText("label7");

        jTableCategoriaVentaBol.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane2.setViewportView(jTableCategoriaVentaBol);

        jButtonRegresarCategoria.setText("Regresar");
        jButtonRegresarCategoria.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButtonRegresarCategoriaMouseClicked(evt);
            }
        });

        jButtonSolicitarEntradasCate.setText("Solicitar entradas en categoria");
        jButtonSolicitarEntradasCate.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButtonSolicitarEntradasCateMouseClicked(evt);
            }
        });

        javax.swing.GroupLayout jFrameEntradasPorCategoriaLayout = new javax.swing.GroupLayout(jFrameEntradasPorCategoria.getContentPane());
        jFrameEntradasPorCategoria.getContentPane().setLayout(jFrameEntradasPorCategoriaLayout);
        jFrameEntradasPorCategoriaLayout.setHorizontalGroup(
            jFrameEntradasPorCategoriaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jFrameEntradasPorCategoriaLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jFrameEntradasPorCategoriaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(label4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jFrameEntradasPorCategoriaLayout.createSequentialGroup()
                        .addComponent(label5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(labelNomEstadio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jFrameEntradasPorCategoriaLayout.createSequentialGroup()
                        .addComponent(label6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(labelNumPartido, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(label7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 452, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jFrameEntradasPorCategoriaLayout.createSequentialGroup()
                        .addComponent(jButtonRegresarCategoria)
                        .addGap(18, 18, 18)
                        .addComponent(jButtonSolicitarEntradasCate)))
                .addContainerGap(84, Short.MAX_VALUE))
        );
        jFrameEntradasPorCategoriaLayout.setVerticalGroup(
            jFrameEntradasPorCategoriaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jFrameEntradasPorCategoriaLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jFrameEntradasPorCategoriaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(labelNomEstadio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jFrameEntradasPorCategoriaLayout.createSequentialGroup()
                        .addComponent(label4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(label5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jFrameEntradasPorCategoriaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(label6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(labelNumPartido, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(label7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jFrameEntradasPorCategoriaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButtonRegresarCategoria)
                    .addComponent(jButtonSolicitarEntradasCate))
                .addContainerGap(71, Short.MAX_VALUE))
        );

        jFrameSeleccionSillas.setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        jFrameSeleccionSillas.setBounds(new java.awt.Rectangle(100, 50, 600, 350));

        labelFrameSillas1.setText("Selección de sillas");

        labelFrameSillas2.setText("Estadio:");

        labelFrameSillasEstadio.setText("label10");

        labelFrameSillas3.setText("Partido:");

        labelFrameSillasIdPartido.setText("label12");

        labelFrameSillas4.setText("Categoría");

        labelFrameSillasNumCat.setText("label14");

        labelFrameSillas5.setText("Disponibles:");

        labelFrameSillasNumDis.setText("label8");

        jButtonFrameSillasRegresar.setText("Regresar");
        jButtonFrameSillasRegresar.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButtonFrameSillasRegresarMouseClicked(evt);
            }
        });

        jButtonFrameSillasComprar.setText("Comprar");
        jButtonFrameSillasComprar.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButtonFrameSillasComprarMouseClicked(evt);
            }
        });

        jTableSillasDisponibles.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane3.setViewportView(jTableSillasDisponibles);

        javax.swing.GroupLayout jFrameSeleccionSillasLayout = new javax.swing.GroupLayout(jFrameSeleccionSillas.getContentPane());
        jFrameSeleccionSillas.getContentPane().setLayout(jFrameSeleccionSillasLayout);
        jFrameSeleccionSillasLayout.setHorizontalGroup(
            jFrameSeleccionSillasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jFrameSeleccionSillasLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jFrameSeleccionSillasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(labelFrameSillas1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jFrameSeleccionSillasLayout.createSequentialGroup()
                        .addGroup(jFrameSeleccionSillasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(labelFrameSillas2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(labelFrameSillas3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(labelFrameSillas4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(labelFrameSillas5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jFrameSeleccionSillasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(labelFrameSillasNumDis, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(labelFrameSillasNumCat, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(labelFrameSillasIdPartido, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(jFrameSeleccionSillasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                .addGroup(jFrameSeleccionSillasLayout.createSequentialGroup()
                                    .addComponent(jButtonFrameSillasRegresar)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(jButtonFrameSillasComprar))
                                .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 375, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jFrameSeleccionSillasLayout.createSequentialGroup()
                                .addComponent(labelFrameSillasEstadio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(51, 51, 51)))))
                .addContainerGap(96, Short.MAX_VALUE))
        );
        jFrameSeleccionSillasLayout.setVerticalGroup(
            jFrameSeleccionSillasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jFrameSeleccionSillasLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jFrameSeleccionSillasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jFrameSeleccionSillasLayout.createSequentialGroup()
                        .addComponent(labelFrameSillas1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(labelFrameSillas2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(labelFrameSillasEstadio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jFrameSeleccionSillasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(labelFrameSillas3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(labelFrameSillasIdPartido, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jFrameSeleccionSillasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(labelFrameSillas4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(labelFrameSillasNumCat, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jFrameSeleccionSillasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(labelFrameSillas5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(labelFrameSillasNumDis, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(jFrameSeleccionSillasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButtonFrameSillasRegresar)
                    .addComponent(jButtonFrameSillasComprar))
                .addGap(222, 222, 222))
        );

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jButtonVentaBoleteria.setText("Venta de boleteria");
        jButtonVentaBoleteria.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButtonVentaBoleteriaMouseClicked(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(64, 64, 64)
                .addComponent(jButtonVentaBoleteria)
                .addContainerGap(150, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(215, 215, 215)
                .addComponent(jButtonVentaBoleteria)
                .addContainerGap(87, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButtonVentaBoleteriaMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButtonVentaBoleteriaMouseClicked
        this.setVisible(false);
        this.jFrameVentaBoleteria.setVisible(true);
        llenarFasesComboBox();
        ventaBoleteria();
    }//GEN-LAST:event_jButtonVentaBoleteriaMouseClicked

    private void jButtonRegresarVentasBol1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonRegresarVentasBol1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jButtonRegresarVentasBol1ActionPerformed

    private void jButtonRegresarVentasBol1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButtonRegresarVentasBol1MouseClicked
        refrescarJtableCalendarioPartidos();
        this.setVisible(true);
        this.jFrameVentaBoleteria.setVisible(false);
    }//GEN-LAST:event_jButtonRegresarVentasBol1MouseClicked

    private void jTableCalendarioPartidosMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTableCalendarioPartidosMouseClicked
        // TODO add your handling code here:
    }//GEN-LAST:event_jTableCalendarioPartidosMouseClicked

    private void jButtonSolicitarEntradasMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButtonSolicitarEntradasMouseClicked
        boolean marcoRadioBut = false;
        for (Enumeration<AbstractButton> elements = butGruopPartidosVentaBol.getElements(); elements.hasMoreElements();) {
            AbstractButton button = elements.nextElement();
            if (button.isSelected()) {
                marcoRadioBut = true;
                BigDecimal auxNumSillDisp = mapSillasDispoPartido.get(button.getText());
                if (auxNumSillDisp.intValue() == 0) {
                    JOptionPane.showMessageDialog(null, "No existen entradas para este partido",
                            "Advertencia", JOptionPane.ERROR_MESSAGE);
                } else {
                    //Seguir con el proceso
                    this.jFrameEntradasPorCategoria.setVisible(true);
                    this.jFrameVentaBoleteria.setVisible(false);
                    for (Partido partido : listPartidosVentaBol) {
                        if (partido.getIdPartido().toString().equalsIgnoreCase(button.getText())) {
                            ventaBoleteriaCategoria(partido, auxNumSillDisp);
                            break;
                        }
                    }

                }
                break;
            }
        }
        if (!marcoRadioBut) {
            JOptionPane.showMessageDialog(null, "Debe seleccionar un partido",
                    "Advertencia", JOptionPane.INFORMATION_MESSAGE);
        }
    }//GEN-LAST:event_jButtonSolicitarEntradasMouseClicked

    private void jButtonSolicitarEntradasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonSolicitarEntradasActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jButtonSolicitarEntradasActionPerformed

    private void jButtonRegresarCategoriaMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButtonRegresarCategoriaMouseClicked
        this.jFrameVentaBoleteria.setVisible(true);
        this.jFrameEntradasPorCategoria.setVisible(false);
        ventaBoleteria();
    }//GEN-LAST:event_jButtonRegresarCategoriaMouseClicked

    private void jButtonSolicitarEntradasCateMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButtonSolicitarEntradasCateMouseClicked
        int i = 0;
        boolean marcoRadioBut = false;
        for (Enumeration<AbstractButton> elements = butGruopCategoriaVentaBol.getElements(); elements.hasMoreElements();) {
            AbstractButton button = elements.nextElement();
            if (button.isSelected()) {
                marcoRadioBut = true;
                System.out.println("tam list precios: " + listPrecioCat.size()
                        + "  indice i: " + i + "   tam listSillas: " + listsillasDispoCategoria.size());
                System.out.println("list precios: " + listPrecioCat.toString());
                System.out.println("List sillas: " + listsillasDispoCategoria.toString());
                BigDecimal auxNumSillDisp = listsillasDispoCategoria.get(i);
                if (auxNumSillDisp.intValue() == 0) {
                    JOptionPane.showMessageDialog(null, "No existen entradas para esta categoria",
                            "Advertencia", JOptionPane.ERROR_MESSAGE);
                } else {
                    //Seguir con el proceso
                    this.jFrameEntradasPorCategoria.setVisible(false);
                    this.jFrameSeleccionSillas.setVisible(true);
                    ventaBoleteriaSillas(button.getText(), listPrecioCat.get(i), listsillasDispoCategoria.get(i));
                    break;

                }
                break;
            }
            i++;
        }
        if (!marcoRadioBut) {
            JOptionPane.showMessageDialog(null, "Debe seleccionar una categoría",
                    "Advertencia", JOptionPane.INFORMATION_MESSAGE);
        }
    }//GEN-LAST:event_jButtonSolicitarEntradasCateMouseClicked

    private void jButtonCargarFaseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCargarFaseActionPerformed

    }//GEN-LAST:event_jButtonCargarFaseActionPerformed

    private void jButtonCargarFaseMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButtonCargarFaseMouseClicked
        ventaBoleteria();
    }//GEN-LAST:event_jButtonCargarFaseMouseClicked

    private void jButtonFrameSillasRegresarMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButtonFrameSillasRegresarMouseClicked
        this.jFrameSeleccionSillas.setVisible(false);
        this.jFrameEntradasPorCategoria.setVisible(true);
    }//GEN-LAST:event_jButtonFrameSillasRegresarMouseClicked
    
    private void jButtonFrameSillasComprarMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButtonFrameSillasComprarMouseClicked
        listSillasSeleccionadasPorUsuario= new ArrayList<>();
        TableModel model = this.jTableSillasDisponibles.getModel();
        int rowCount = model.getRowCount();
        int columnCount = model.getColumnCount();
        System.out.println("RowCount: "+rowCount+"  -  ColumnCount: "+columnCount);
        for (int i = 0; i < rowCount; i++) {       
            for(int j= 1; j< columnCount; j++)
            {
                Object obAux= model.getValueAt(i, j);
                if( obAux instanceof JCheckBox)
                {
                    JCheckBox boxAux= (JCheckBox) obAux;
                    if(boxAux.isSelected())
                    {
                        listSillasSeleccionadasPorUsuario.add(new Silla(new BigInteger(Integer.toString(i+1)),
                               new BigInteger(Integer.toString(j)),  
                                new BigInteger(this.labelFrameSillasNumCat.getText()),
                                partidoSeleccionadoVenta.getEstadioIdEstadio().getIdEstadio().toBigInteger()));
                    }
                }
            }
        }
        if(listSillasSeleccionadasPorUsuario.isEmpty())
        {
            JOptionPane.showMessageDialog(null, "Debe seleccionar alguna sillas para poder continuar",
                    "Advertencia", JOptionPane.INFORMATION_MESSAGE);
        }
        else{
            for (Silla sillaA : listSillasSeleccionadasPorUsuario) {
                System.out.println("Fila: "+sillaA.getSillaPK().getNumeroFila().toString()
                        +"  -  Asiento: "+sillaA.getSillaPK().getNumeroAsiento().toString());
            }
            int tam= listSillasSeleccionadasPorUsuario.size();
            Object[][] objs = new Object[tam][2];
            int cuenta=0, asignacion=0;
            int filaInt=0;
            
            while(cuenta<tam-1){
            
                String auxFila= listSillasSeleccionadasPorUsuario.get(cuenta).getSillaPK().getNumeroFila().toString();
            
            objs[filaInt][0]= auxFila;
            objs[filaInt][1]= listSillasSeleccionadasPorUsuario.get(cuenta).getSillaPK().getNumeroAsiento().toString();
            asignacion++;
            while(cuenta<tam-1)
            {
                cuenta++;
                if(auxFila.equalsIgnoreCase(listSillasSeleccionadasPorUsuario.get(cuenta).getSillaPK().getNumeroFila().toString()))
                {
                    asignacion++;
                   objs[filaInt][1]+= ", "+listSillasSeleccionadasPorUsuario.get(cuenta).getSillaPK().getNumeroAsiento().toString(); 
                }
                else
                {
                   break; 
                }
            }
            filaInt++;
            }
            
            if(asignacion<tam)
            {
                objs[filaInt][0]= listSillasSeleccionadasPorUsuario.get(cuenta).getSillaPK().getNumeroFila().toString();
                objs[filaInt][1]=listSillasSeleccionadasPorUsuario.get(cuenta).getSillaPK().getNumeroAsiento().toString();
            }
            int cantidadTotalFilas=0;
            for(int i=0; i<=filaInt; i++)
            {
                System.out.println("");
                if(objs[i][0] != null){
                  cantidadTotalFilas++;
                }
                for(int j=0;j<2;j++)
                {
                    if(objs[i][j] != null){
                        System.out.print(objs[i][j]+" - ");                        
                    }
                    else
                    {
                        System.out.print("null");
                    }
                }                
            }
            
            Object[][] objFinal = new Object[cantidadTotalFilas][2];
            for(int i=0; i< cantidadTotalFilas;i++)
            {
                System.out.println("");
                for(int j=0;j<2;j++)
                {
                    objFinal[i][j]=  objs[i][j];
                    System.out.print(objFinal[i][j]+" - ");
                }
            }
        }
    }//GEN-LAST:event_jButtonFrameSillasComprarMouseClicked

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Mundial_GUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Mundial_GUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Mundial_GUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Mundial_GUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Mundial_GUI().setVisible(true);
            }
        });
    }


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.ButtonGroup butGruopPartidosVentaBol;
    private javax.swing.JButton jButtonCargarFase;
    private javax.swing.JButton jButtonFrameSillasComprar;
    private javax.swing.JButton jButtonFrameSillasRegresar;
    private javax.swing.JButton jButtonRegresarCategoria;
    private javax.swing.JButton jButtonRegresarVentasBol1;
    private javax.swing.JButton jButtonSolicitarEntradas;
    private javax.swing.JButton jButtonSolicitarEntradasCate;
    private javax.swing.JButton jButtonVentaBoleteria;
    private javax.swing.JComboBox jComboBoxFases;
    private javax.swing.JFrame jFrameEntradasPorCategoria;
    private javax.swing.JFrame jFrameSeleccionSillas;
    private javax.swing.JFrame jFrameVentaBoleteria;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JTable jTableCalendarioPartidos;
    private javax.swing.JTable jTableCategoriaVentaBol;
    private javax.swing.JTable jTableSillasDisponibles;
    private java.awt.Label label1;
    private java.awt.Label label2;
    private java.awt.Label label3;
    private java.awt.Label label4;
    private java.awt.Label label5;
    private java.awt.Label label6;
    private java.awt.Label label7;
    private java.awt.Label labelFechaActual;
    private java.awt.Label labelFrameSillas1;
    private java.awt.Label labelFrameSillas2;
    private java.awt.Label labelFrameSillas3;
    private java.awt.Label labelFrameSillas4;
    private java.awt.Label labelFrameSillas5;
    private java.awt.Label labelFrameSillasEstadio;
    private java.awt.Label labelFrameSillasIdPartido;
    private java.awt.Label labelFrameSillasNumCat;
    private java.awt.Label labelFrameSillasNumDis;
    private java.awt.Label labelHoraActual;
    private java.awt.Label labelNomEstadio;
    private java.awt.Label labelNumPartido;
    // End of variables declaration//GEN-END:variables
    private List<Partido> listPartidosVentaBol = null;
    List<Categoria> listCategoriasVentaBol = null;
    private Map<String, BigDecimal> mapSillasDispoPartido = null;
    List<BigDecimal> listsillasDispoCategoria = null;
    List<Precio> listPrecioCat = null;
    private javax.swing.ButtonGroup butGruopCategoriaVentaBol = null;
    List<Silla> listSillasCategoriaSelec;
    List<Sillaxpartido> listSillasNODispo;
    Precio precioCategSeleccionada;
    List<Silla> listSillasSeleccionadasPorUsuario;
    private void refrescarJtableCalendarioPartidos() {
        String[] cols = {"Partido", "Fecha", "Sede", "Equipos", "Horario", "Entradas Disponibles"};
        Object[][] objs = new Object[1][cols.length];
        objs[0][0] = "A";
        DefaultTableModel model = new DefaultTableModel(objs, cols);
        this.jTableCalendarioPartidos.setModel(model);
    }

    private void ventaBoleteria() {
        refrescarJtableCalendarioPartidos();
        Date fechaActual = new Date();
        SimpleDateFormat dateToFecha = new SimpleDateFormat("dd-MMM-yy");
        SimpleDateFormat dateToHora = new SimpleDateFormat("HH:mm");
        this.labelFechaActual.setText(dateToFecha.format(fechaActual));
        this.labelHoraActual.setText(dateToHora.format(fechaActual));
        Fase faseAux = (Fase) this.jComboBoxFases.getSelectedItem();
        listPartidosVentaBol = sistema.getListPartidosMayorFecha(fechaActual, faseAux);
        mostrarPartidosEnTabla(listPartidosVentaBol);
    }

    private void llenarFasesComboBox() {
        List<Fase> listFases = sistema.getListFases();
        DefaultComboBoxModel model = new DefaultComboBoxModel();
        for (Fase fase : listFases) {
            model.addElement(fase);
        }
        this.jComboBoxFases.setModel(model);
    }

    private void mostrarPartidosEnTabla(List<Partido> partidoList) {
        UIDefaults ui = UIManager.getLookAndFeel().getDefaults();
        UIManager.put("RadioButton.focus", ui.getColor("control"));
        SimpleDateFormat dateToFecha = new SimpleDateFormat("dd-MMM-yy");
        SimpleDateFormat dateToHora = new SimpleDateFormat("HH:mm");
        String[] cols = {"Partido", "Fecha", "Sede", "Equipos", "Horario", "Entradas Disponibles"};
        Object[][] objs = new Object[partidoList.size()][cols.length];
        mapSillasDispoPartido = new HashMap<String, BigDecimal>();
        butGruopPartidosVentaBol = new ButtonGroup();
        for (int i = 0; i < partidoList.size(); i++) {
            JRadioButton jRadioButton = new JRadioButton(partidoList.get(i).getIdPartido().toString());
            objs[i][0] = jRadioButton;
            objs[i][1] = dateToFecha.format(partidoList.get(i).getFecha());
            objs[i][2] = partidoList.get(i).getEstadioIdEstadio().getLugar();

            if (partidoList.get(i).getEquipoIdEquipo() == null) {
                objs[i][3] = getProximosPartidos(partidoList.get(i));
            } else {
                objs[i][3] = "" + partidoList.get(i).getEquipoIdEquipo().getNombre() + " - "
                        + partidoList.get(i).getEquipoIdEquipo1().getNombre();
            }

            objs[i][4] = dateToHora.format(partidoList.get(i).getHora());
            BigDecimal auxsillasDisp = sistema.getEntradasDispPartido(partidoList.get(i));
            mapSillasDispoPartido.put(partidoList.get(i).getIdPartido().toString(), auxsillasDisp);
            objs[i][5] = auxsillasDisp.toString();
            butGruopPartidosVentaBol.add(jRadioButton);
        }

        DefaultTableModel model = new DefaultTableModel(objs, cols);
        this.jTableCalendarioPartidos.setModel(model);
        this.jTableCalendarioPartidos.getColumn("Partido").setCellRenderer(
                new RadioButtonRenderer());
        this.jTableCalendarioPartidos.getColumn("Partido").setCellEditor(
                new RadioButtonEditor(new JCheckBox()));
    }

    private void ventaBoleteriaCategoria(Partido partido, BigDecimal auxNumSillDisp) {
        this.labelNomEstadio.setText(partido.getEstadioIdEstadio().getNombre());
        this.labelNumPartido.setText(partido.getIdPartido().toString());
        this.label7.setText("Entradas Disponibles: " + auxNumSillDisp.toString());
        listCategoriasVentaBol = sistema.getListCategoriasPorPartido(partido);
        partidoSeleccionadoVenta = partido;
        mostrarCategoriasPartidoEnTabla(partido);
    }

    private String getProximosPartidos(Partido part) {
        switch (part.getIdPartido().intValue()) {
            case 49:
                return "1A - 2B";
            case 50:
                return "1C - 2D";
            case 51:
                return "1B - 2A";
            case 52:
                return "1D - 2C";
            case 53:
                return "1E - 2F";
            case 54:
                return "1G - 2H";
            case 55:
                return "1F - 2E";
            case 56:
                return "1H - 2G";
            case 57:
                return "W53 - W54";
            case 58:
                return "W49 - W50";
            case 59:
                return "W55 - W56";
            case 60:
                return "W51 - W52";
            case 61:
                return "W57 - W58";
            case 62:
                return "W59 - W60";
            case 63:
                return "L61 - L62";
            case 64:
                return "W61 - W62";
        }
        return "";
    }

    private void mostrarCategoriasPartidoEnTabla(Partido part) {
        UIDefaults ui = UIManager.getLookAndFeel().getDefaults();
        UIManager.put("RadioButton.focus", ui.getColor("control"));
        String[] cols = {"Categoria", "Precio (USD)", "Entradas Disponibles"};
        Object[][] objs = new Object[listCategoriasVentaBol.size()][cols.length];
        butGruopCategoriaVentaBol = new ButtonGroup();
        listsillasDispoCategoria = new ArrayList<BigDecimal>();
        listPrecioCat = new ArrayList<Precio>();
        for (int i = 0; i < listCategoriasVentaBol.size(); i++) {
            JRadioButton jRadioButton = new JRadioButton(listCategoriasVentaBol.get(i).getCategoriaPK().getIdCategoria().toString());
            objs[i][0] = jRadioButton;
            Precio auxPrecio = sistema.getPrecioCatXPartido(listCategoriasVentaBol.get(i), part);
            listPrecioCat.add(auxPrecio);
            objs[i][1] = "$"+auxPrecio.getValor().toString();
            BigDecimal auxSillasDisp = sistema.getEntradasDispCategoriaXPartido(listCategoriasVentaBol.get(i), part);
            listsillasDispoCategoria.add(auxSillasDisp);
            objs[i][2] = auxSillasDisp.toString();
            butGruopCategoriaVentaBol.add(jRadioButton);
        }
        DefaultTableModel model = new DefaultTableModel(objs, cols);
        this.jTableCategoriaVentaBol.setModel(model);
        this.jTableCategoriaVentaBol.getColumn("Categoria").setCellRenderer(
                new RadioButtonRenderer());
        this.jTableCategoriaVentaBol.getColumn("Categoria").setCellEditor(
                new RadioButtonEditor(new JCheckBox()));
    }

    private void ventaBoleteriaSillas(String cat, Precio precioCat, BigDecimal dispo) {
        precioCategSeleccionada= precioCat;
        this.labelFrameSillasEstadio.setText(partidoSeleccionadoVenta.getEstadioIdEstadio().getNombre());
        this.labelFrameSillasIdPartido.setText(partidoSeleccionadoVenta.getIdPartido().toString());
        this.labelFrameSillasNumCat.setText(cat);
        this.labelFrameSillasNumDis.setText(dispo.toString());
        listSillasCategoriaSelec = sistema.getListSillasCategoriaEstadio(partidoSeleccionadoVenta, cat);
        listSillasNODispo = sistema.getListSillasOcupadasXPartido(partidoSeleccionadoVenta, cat);

        BigInteger numeroAsiento;
        int numeroAsientoMax = 0;
        int numeroFilaMAx = listSillasCategoriaSelec.get(0).getSillaPK().getNumeroFila().intValue();
        //Sacar el maximo numero de asientos
        for (Silla sillaAux : listSillasCategoriaSelec) {
            numeroAsiento = sillaAux.getSillaPK().getNumeroAsiento();
            if (numeroAsiento.intValue() > numeroAsientoMax) {
                numeroAsientoMax = numeroAsiento.intValue();
            }
        }
        System.out.println("Maxima Fila: " + numeroFilaMAx);
        System.out.println("Maximo asiento: " + numeroAsientoMax);

        mostrarSillasDisponiblesEnTabla(numeroFilaMAx, numeroAsientoMax);
    }

    private void mostrarSillasDisponiblesEnTabla(int numeroFilaMAx, int numeroAsientoMax) {

        String[] cols = new String[numeroAsientoMax + 1];
        cols[0] = "Fila/Silla";
        for (int j = 1; j <= numeroAsientoMax; j++) {
            cols[j] = Integer.toString(j);
        }
        Object[][] objs = new Object[numeroFilaMAx][numeroAsientoMax + 1];
        for (int i = 0; i < numeroFilaMAx; i++) {
            objs[i][0] = i + 1;
        }

        for(Silla silla: listSillasCategoriaSelec)
        {
            int filaAux = silla.getSillaPK().getNumeroFila().intValue() - 1;
            int columAux = silla.getSillaPK().getNumeroAsiento().intValue();
            objs[filaAux][columAux]= new JCheckBox();
        }
        
        for(Sillaxpartido sillaPartido: listSillasNODispo)
        {
            int filaAux = sillaPartido.getSillaxpartidoPK().getSillaNumeroFila().intValue()-1;
            int columAux = sillaPartido.getSillaxpartidoPK().getSillaNumeroAsiento().intValue();
            java.awt.Label l= new Label("Ocupado");
            objs[filaAux][columAux]= l;     
        }
        
        for(int i=0; i<numeroFilaMAx;i++){
            for(int j=1; j<=numeroAsientoMax; j++)
            {
                if(objs[i][j]==null)
                {
                    java.awt.Label l= new Label("No vale");
                    objs[i][j]=l;
                }
            }
        }
            
        DefaultTableModel model = new DefaultTableModel(objs, cols);
        this.jTableSillasDisponibles.setModel(model);
        
        for (int j = 1; j <= numeroAsientoMax; j++) {
            String colA = jTableSillasDisponibles.getColumnName(j);            
            this.jTableSillasDisponibles.getColumn(colA).setCellRenderer(
                    new CheckBoxRenderer());
            this.jTableSillasDisponibles.getColumn(colA).setCellEditor(
                    new CheckBoxEditor(new JCheckBox()));
        }
    }

}
